<script setup>
import { defineAsyncComponent, watch } from "vue";
const props = defineProps({
  name: { type: String, default: "" },
});

const svgModules = import.meta.glob("@/assets/svg/**/*.svg", {
  query: "?component",
});

const SvgComponent = defineAsyncComponent(
  svgModules[`/src/assets/svg/${props.name}.svg`]
);
watch(() => props.name, (val) => {
  SvgComponent.then((res) => {
    res.name = val
  })
})
</script>

<template>
  <SvgComponent class="tw-svgicon" :class="`x${props.name}`" />
</template>
<script>
export default {
  name: 'SvgIcon'
}
</script>
<style lang="scss" scoped>

.tw-svgicon {
  overflow: hidden;
  vertical-align: middle;
}

.tw-svgicon .xhover,
.tw-svgicon .xactive,
*.xsvgactive .xhover,
*.xsvgactive .xdefault,
*.xsvghover:hover .xdefault {
  display: none;
}

*.xsvgactive .xactive,
*.xsvghover:hover .xhover {
  display: inline;
}

.tw-svgicon {
  overflow: hidden;
  width: 16px;
  height: 16px;
}
.tw-svgicon.xfolder {
  width: 100%;
  height: 100px;
}
.tw-svgicon.xfolder-table {
  width: auto;
  height: 16px;
}
.tw-svgicon.x12 {
  width: 12px;
  height: 12px;
}
.tw-svgicon.x16 {
  width: 16px;
  height: 16px;
}
.tw-svgicon.x18 {
  width: 18px;
  height: 18px;
}

.tw-svgicon.x24 {
  width: 24px;
  height: 24px;
}

.tw-svgicon.x22 {
  width: 22px;
  height: 22px;
}

.tw-svgicon.x20 {
  width: 20px;
  height: 20px;
}

.tw-svgicon.x28 {
  width: 28px;
  height: 28px;
}
.tw-svgicon.x26 {
  width: 26px;
  height: 26px;
}

.tw-svgicon.x32 {
  width: 32px;
  height: 32px;
}

.tw-svgicon.x36 {
  width: 36px;
  height: 36px;
}

.tw-svgicon.x40 {
  width: 40px;
  height: 40px;
}

.tw-svgicon.x48 {
  width: 48px;
  height: 48px;
}

.tw-svgicon.x56 {
  width: 56px;
  height: 56px;
}
.tw-svgicon.x64 {
  width: 64px;
  height: 64px;
}

.tw-svgicon.x80 {
  width: 80px;
  height: 80px;
}
.tw-svgicon.x88 {
  width: 88px;
  height: 88px;
}
.tw-svgicon.x92 {
  width: 92px;
  height: 92px;
}

.tw-svgicon.x120 {
  width: 120px;
  height: 120px;
}

.tw-svgicon.x140 {
  width: 140px;
  height: 140px;
}

.tw-svgicon.x160 {
  width: 160px;
  height: 160px;
}
.tw-svgicon.x200 {
  width: 200px;
  height: 200px;
}

.tw-svgicon.xprotractor {
  width: 550px;
  height: 277px;
}

</style>
